package com.franklin.ideaplugin.api.utils;

/**
 * @author Ye Junhui
 * @since 2023/5/23
 */
public class UiUtils {

    /**
     * 将字符按 宽度换行
     * @param data
     * @param width
     * @return
     */
    public static String splitLine(String data,int width){
        int lineCount = width / 7;
        if (width % 7 != 0){
            lineCount = lineCount + 1;
        }
        int countTemp = 0;
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < data.length(); i++) {
            if (countTemp < lineCount){
                builder.append(data.charAt(i));
            }else {
                countTemp = 0;
                builder.append('\n');
            }
        }
        return builder.toString();
    }

}
